<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">

<title>parent - rexml: Ruby Standard Library Documentation</title>


<script src="../../../../../js/navigation.js" defer></script>
<script src="../../../../../js/search.js" defer></script>
<script src="../../../../../js/search_index.js" defer></script>
<script src="../../../../../js/searcher.js" defer></script>
<script src="../../../../../js/darkfish.js" defer></script>

<script src="../../../../../js/jquery-3.2.0.min.js"></script>

<script src="../../../../../js/vue.min.js"></script>
<script src="../../../../../js/js.cookie.min.js"></script>

<link href="../../../../../css/fonts.css" rel="stylesheet">
<link id='rdoccss' href="../../../../../css/rdoc.css" rel="stylesheet">
<link href="../../../../../css/carbon17.css" rel="stylesheet">

<script type="text/javascript">
  var rdoc_rel_prefix = "../../../../../";
  var index_rel_prefix = "../../../../../";
  var darkModeCsseHref = "../../../../../css/rdoc-dm.css"
  var defaultModeCssHref = "../../../../../css/rdoc.css"
  // var cssDarkmode = Cookies.get('darkmode');
  
  if( Cookies.get("darkmode") == "true") {
	$('#rdoccss').attr("href", darkModeCsseHref);
}

//  https://cssdeck.com/blog/simple-jquery-stylesheet-switcher/

document.write('<style type="text/css">body{display:none}</style>');

</script>


</head>
<body id="top" role="document" class="file">
  <!-- this is page.html -->
  <div id='actionbar' >
    <div class='wrapper mdiv'>
      <ul class='grids g0'></ul>
    </div> 
    <!-- VERSION HEADER for 3.3.0.preview2 NOT FOUND -->
  </div> <!-- end action bar -->


 <div class='wrapper hdiv'>

 


<nav id='vapp' role="navigation">
  <div id="project-navigation">
    <div id="home-section" role="region" title="Quick navigation" class="nav-section">
  <h2><a href="../../../../../index.html" rel="home">Home</a></h2>

  <div id="table-of-contents-navigation"  >
    <a href="../../../../../table_of_contents.html#pages">Pages</a>
    <a href="../../../../../table_of_contents.html#classes">Classes</a>
    <a href="../../../../../table_of_contents.html#methods">Methods</a>
  </div>
</div>

    <div id="search-section" role="search" class="project-section initially-hidden">
  <form action="#" method="get" accept-charset="utf-8">
    <div id="search-field-wrapper">
      <input id="search-field" role="combobox" aria-label="Search"
             aria-autocomplete="list" aria-controls="search-results"
             type="text" name="search" placeholder="Search" spellcheck="false"
             title="Type to search, Up and Down to navigate, Enter to load">
    </div>

    <ul id="search-results" aria-label="Search Results"
        aria-busy="false" aria-expanded="false"
        aria-atomic="false" class="initially-hidden"></ul>
  </form>
</div>

  </div>

  
<div class="nav-section">
  <h3>Table of Contents</h3>

  <ul class="link-list" role="directory">
    <li><a href="#label-Class+Parent">Class Parent</a>
    <li><a href="#label-Queries">Queries</a>
    <li><a href="#label-Task-3A+Get+the+Count+of+Children">Task: Get the Count of Children</a>
    <li><a href="#label-Task-3A+Get+the+Child+at+a+Given+Index">Task: Get the Child at a Given Index</a>
    <li><a href="#label-Task-3A+Get+the+Index+of+a+Given+Child">Task: Get the Index of a Given Child</a>
    <li><a href="#label-Task-3A+Get+the+Children">Task: Get the Children</a>
    <li><a href="#label-Task-3A+Determine+Whether+the+Node+is+a+Parent">Task: Determine Whether the Node is a Parent</a>
    <li><a href="#label-Additions">Additions</a>
    <li><a href="#label-Task-3A+Add+a+Child+at+the+Beginning">Task: Add a Child at the Beginning</a>
    <li><a href="#label-Task-3A+Add+a+Child+at+the+End">Task: Add a Child at the End</a>
    <li><a href="#label-Task-3A+Replace+a+Child+with+Another+Child">Task: Replace a Child with Another Child</a>
    <li><a href="#label-Task-3A+Replace+Multiple+Children+with+Another+Child">Task: Replace Multiple Children with Another Child</a>
    <li><a href="#label-Task-3A+Insert+Child+Before+a+Given+Child">Task: Insert Child Before a Given Child</a>
    <li><a href="#label-Task-3A+Insert+Child+After+a+Given+Child">Task: Insert Child After a Given Child</a>
    <li><a href="#label-Deletions">Deletions</a>
    <li><a href="#label-Task-3A+Remove+a+Given+Child">Task: Remove a Given Child</a>
    <li><a href="#label-Task-3A+Remove+the+Child+at+a+Specified+Offset">Task: Remove the Child at a Specified Offset</a>
    <li><a href="#label-Task-3A+Remove+Children+That+Meet+Specified+Criteria">Task: Remove Children That Meet Specified Criteria</a>
    <li><a href="#label-Iterations">Iterations</a>
    <li><a href="#label-Task-3A+Iterate+Over+Children">Task: Iterate Over Children</a>
    <li><a href="#label-Task-3A+Iterate+Over+Child+Indexes">Task: Iterate Over Child Indexes</a>
    <li><a href="#label-Clones">Clones</a>
    <li><a href="#label-Task-3A+Clone+Deeply">Task: Clone Deeply</a>
  </ul>
</div>

  <button id='toggleThing' @click="toggleNav()" >Show/hide navigation</button>

  <div id="project-metadata">
   <div :class="isOpen ? 'block' : 'hidden' " id='toggleMe'>
    
<div id="fileindex-section" class="nav-section">
  <h3>Pages</h3>

  <ul class="link-list">
    <li><a href="../../../../../rexml-3_2_6/doc/rexml/context_rdoc.html">context</a>
    <li><a href="../../../../../rexml-3_2_6/doc/rexml/tasks/rdoc/child_rdoc.html">child</a>
    <li><a href="../../../../../rexml-3_2_6/doc/rexml/tasks/rdoc/document_rdoc.html">document</a>
    <li><a href="../../../../../rexml-3_2_6/doc/rexml/tasks/rdoc/element_rdoc.html">element</a>
    <li><a href="../../../../../rexml-3_2_6/doc/rexml/tasks/rdoc/node_rdoc.html">node</a>
    <li><a href="../../../../../rexml-3_2_6/doc/rexml/tasks/rdoc/parent_rdoc.html">parent</a>
    <li><a href="../../../../../rexml-3_2_6/doc/rexml/tasks/tocs/child_toc_rdoc.html">child_toc</a>
    <li><a href="../../../../../rexml-3_2_6/doc/rexml/tasks/tocs/document_toc_rdoc.html">document_toc</a>
    <li><a href="../../../../../rexml-3_2_6/doc/rexml/tasks/tocs/element_toc_rdoc.html">element_toc</a>
    <li><a href="../../../../../rexml-3_2_6/doc/rexml/tasks/tocs/master_toc_rdoc.html">master_toc</a>
    <li><a href="../../../../../rexml-3_2_6/doc/rexml/tasks/tocs/node_toc_rdoc.html">node_toc</a>
    <li><a href="../../../../../rexml-3_2_6/doc/rexml/tasks/tocs/parent_toc_rdoc.html">parent_toc</a>
    <li><a href="../../../../../rexml-3_2_6/doc/rexml/tutorial_rdoc.html">tutorial</a>
  </ul>
</div>

   </div>
  </div>
</nav>


<!--  carbon ads here -->

<div id='extraz'>
  <div class='adzbox-index'  >
   
  </div>
 </div>         


<main role="main" aria-label="Page rexml-3.2.6/doc/rexml/tasks/rdoc/parent.rdoc">

<h2 id="label-Class+Parent">Class Parent<span><a href="#label-Class+Parent">&para;</a> <a href="#top">&uarr;</a></span></h2>

<p>Class Parent has methods from its superclasses and included modules; see:</p>
<ul><li>
<p><a href="child_rdoc.html">Tasks for Child</a>.</p>
</li><li>
<p><a href="node_rdoc.html">Tasks for Node</a>.</p>
</li><li>
<p><a href="https://docs.ruby-lang.org/en/master/Enumerable.html">Module Enumerable</a>.</p>
</li></ul>

<p>Tasks on this page:</p>
<ul><li>
<p><a href="#label-Queries">Queries</a></p>
<ul><li>
<p><a href="#label-Task-3A+Get+the+Count+of+Children">Task: Get the Count of Children</a></p>
</li><li>
<p><a href="#label-Task-3A+Get+the+Child+at+a+Given+Index">Task: Get the Child at a Given Index</a></p>
</li><li>
<p><a href="#label-Task-3A+Get+the+Index+of+a+Given+Child">Task: Get the Index of a Given Child</a></p>
</li><li>
<p><a href="#label-Task-3A+Get+the+Children">Task: Get the Children</a></p>
</li><li>
<p><a href="#label-Task-3A+Determine+Whether+the+Node+is+a+Parent">Task: Determine Whether the Node is a Parent</a></p>
</li></ul>
</li><li>
<p><a href="#label-Additions">Additions</a></p>
<ul><li>
<p><a href="#label-Task-3A+Add+a+Child+at+the+Beginning">Task: Add a Child at the Beginning</a></p>
</li><li>
<p><a href="#label-Task-3A+Add+a+Child+at+the+End">Task: Add a Child at the End</a></p>
</li><li>
<p><a href="#label-Task-3A+Replace+a+Child+with+Another+Child">Task: Replace a Child with Another Child</a></p>
</li><li>
<p><a href="#label-Task-3A+Replace+Multiple+Children+with+Another+Child">Task: Replace Multiple Children with Another Child</a></p>
</li><li>
<p><a href="#label-Task-3A+Insert+Child+Before+a+Given+Child">Task: Insert Child Before a Given Child</a></p>
</li><li>
<p><a href="#label-Task-3A+Insert+Child+After+a+Given+Child">Task: Insert Child After a Given Child</a></p>
</li></ul>
</li><li>
<p><a href="#label-Deletions">Deletions</a></p>
<ul><li>
<p><a href="#label-Task-3A+Remove+a+Given+Child">Task: Remove a Given Child</a></p>
</li><li>
<p><a href="#label-Task-3A+Remove+the+Child+at+a+Specified+Offset">Task: Remove the Child at a Specified Offset</a></p>
</li><li>
<p><a href="#label-Task-3A+Remove+Children+That+Meet+Specified+Criteria">Task: Remove Children That Meet Specified Criteria</a></p>
</li></ul>
</li><li>
<p><a href="#label-Iterations">Iterations</a></p>
<ul><li>
<p><a href="#label-Task-3A+Iterate+Over+Children">Task: Iterate Over Children</a></p>
</li><li>
<p><a href="#label-Task-3A+Iterate+Over+Child+Indexes">Task: Iterate Over Child Indexes</a></p>
</li></ul>
</li><li>
<p><a href="#label-Clones">Clones</a></p>
<ul><li>
<p><a href="#label-Task-3A+Clone+Deeply">Task: Clone Deeply</a></p>
</li></ul>
</li></ul>

<h3 id="label-Queries">Queries<span><a href="#label-Queries">&para;</a> <a href="#top">&uarr;</a></span></h3>

<h4 id="label-Task-3A+Get+the+Count+of+Children">Task: Get the Count of Children<span><a href="#label-Task-3A+Get+the+Count+of+Children">&para;</a> <a href="#top">&uarr;</a></span></h4>

<p>Use method <a href="../../../../REXML/Parent.html#method-i-size">Parent#size</a> (or its alias <code>length</code>) to get the count of the parent’s children:</p>

<pre class="ruby"><span class="ruby-identifier">p</span> = <span class="ruby-constant">REXML</span><span class="ruby-operator">::</span><span class="ruby-constant">Parent</span>.<span class="ruby-identifier">new</span>
<span class="ruby-identifier">p</span>.<span class="ruby-identifier">size</span> <span class="ruby-comment"># =&gt; 0</span>
<span class="ruby-identifier">xml_string</span> = <span class="ruby-string">&#39;&lt;root&gt;&lt;a/&gt;&lt;b/&gt;&lt;c/&gt;&lt;/root&gt;&#39;</span>
<span class="ruby-identifier">d</span> = <span class="ruby-constant">REXML</span><span class="ruby-operator">::</span><span class="ruby-constant">Document</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">xml_string</span>)
<span class="ruby-identifier">d</span>.<span class="ruby-identifier">root</span>.<span class="ruby-identifier">size</span> <span class="ruby-comment"># =&gt; 3</span>
</pre>

<h4 id="label-Task-3A+Get+the+Child+at+a+Given+Index">Task: Get the Child at a Given Index<span><a href="#label-Task-3A+Get+the+Child+at+a+Given+Index">&para;</a> <a href="#top">&uarr;</a></span></h4>

<p>Use method <a href="../../../../REXML/Parent.html#method-i-5B-5D">Parent#[]</a> to get the child at a given index:</p>

<pre class="ruby"><span class="ruby-identifier">xml_string</span> = <span class="ruby-string">&#39;&lt;root&gt;&lt;a/&gt;&lt;b/&gt;&lt;c/&gt;&lt;/root&gt;&#39;</span>
<span class="ruby-identifier">d</span> = <span class="ruby-constant">REXML</span><span class="ruby-operator">::</span><span class="ruby-constant">Document</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">xml_string</span>)
<span class="ruby-identifier">d</span>.<span class="ruby-identifier">root</span>[<span class="ruby-value">1</span>]  <span class="ruby-comment"># =&gt; &lt;b/&gt;</span>
<span class="ruby-identifier">d</span>.<span class="ruby-identifier">root</span>[<span class="ruby-value">-1</span>] <span class="ruby-comment"># =&gt; &lt;c/&gt;</span>
<span class="ruby-identifier">d</span>.<span class="ruby-identifier">root</span>[<span class="ruby-value">50</span>] <span class="ruby-comment"># =&gt; nil</span>
</pre>

<h4 id="label-Task-3A+Get+the+Index+of+a+Given+Child">Task: Get the Index of a Given Child<span><a href="#label-Task-3A+Get+the+Index+of+a+Given+Child">&para;</a> <a href="#top">&uarr;</a></span></h4>

<p>Use method <a href="../../../../REXML/Parent.html#method-i-index">Parent#index</a> to get the index (0-based offset) of a child:</p>

<pre class="ruby"><span class="ruby-identifier">d</span> = <span class="ruby-constant">REXML</span><span class="ruby-operator">::</span><span class="ruby-constant">Document</span>.<span class="ruby-identifier">new</span>(<span class="ruby-string">&#39;&lt;root&gt;&lt;/root&gt;&#39;</span>)
<span class="ruby-identifier">root</span> = <span class="ruby-identifier">d</span>.<span class="ruby-identifier">root</span>
<span class="ruby-identifier">e0</span> = <span class="ruby-constant">REXML</span><span class="ruby-operator">::</span><span class="ruby-constant">Element</span>.<span class="ruby-identifier">new</span>(<span class="ruby-string">&#39;foo&#39;</span>)
<span class="ruby-identifier">e1</span> = <span class="ruby-constant">REXML</span><span class="ruby-operator">::</span><span class="ruby-constant">Element</span>.<span class="ruby-identifier">new</span>(<span class="ruby-string">&#39;bar&#39;</span>)
<span class="ruby-identifier">root</span>.<span class="ruby-identifier">add</span>(<span class="ruby-identifier">e0</span>)  <span class="ruby-comment"># =&gt; &lt;foo/&gt;</span>
<span class="ruby-identifier">root</span>.<span class="ruby-identifier">add</span>(<span class="ruby-identifier">e1</span>)  <span class="ruby-comment"># =&gt; &lt;bar/&gt;</span>
<span class="ruby-identifier">root</span>.<span class="ruby-identifier">add</span>(<span class="ruby-identifier">e0</span>)  <span class="ruby-comment"># =&gt; &lt;foo/&gt;</span>
<span class="ruby-identifier">root</span>.<span class="ruby-identifier">add</span>(<span class="ruby-identifier">e1</span>)  <span class="ruby-comment"># =&gt; &lt;bar/&gt;</span>
<span class="ruby-identifier">root</span>.<span class="ruby-identifier">index</span>(<span class="ruby-identifier">e0</span>) <span class="ruby-comment"># =&gt; 0</span>
<span class="ruby-identifier">root</span>.<span class="ruby-identifier">index</span>(<span class="ruby-identifier">e1</span>) <span class="ruby-comment"># =&gt; 1</span>
</pre>

<h4 id="label-Task-3A+Get+the+Children">Task: Get the Children<span><a href="#label-Task-3A+Get+the+Children">&para;</a> <a href="#top">&uarr;</a></span></h4>

<p>Use method <a href="../../../../REXML/Parent.html#method-i-children">Parent#children</a> (or its alias <code>to_a</code>) to get the parent’s children:</p>

<pre class="ruby"><span class="ruby-identifier">xml_string</span> = <span class="ruby-string">&#39;&lt;root&gt;&lt;a/&gt;&lt;b/&gt;&lt;c/&gt;&lt;/root&gt;&#39;</span>
<span class="ruby-identifier">d</span> = <span class="ruby-constant">REXML</span><span class="ruby-operator">::</span><span class="ruby-constant">Document</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">xml_string</span>)
<span class="ruby-identifier">d</span>.<span class="ruby-identifier">root</span>.<span class="ruby-identifier">children</span> <span class="ruby-comment"># =&gt; [&lt;a/&gt;, &lt;b/&gt;, &lt;c/&gt;]</span>
</pre>

<h4 id="label-Task-3A+Determine+Whether+the+Node+is+a+Parent">Task: Determine Whether the Node is a Parent<span><a href="#label-Task-3A+Determine+Whether+the+Node+is+a+Parent">&para;</a> <a href="#top">&uarr;</a></span></h4>

<p>Use method <a href="../../../../REXML/Parent.html#method-i-parent-3F">Parent#parent?</a> to determine whether the node is a parent; class Text derives from Node:</p>

<pre class="ruby"><span class="ruby-identifier">d</span> = <span class="ruby-constant">REXML</span><span class="ruby-operator">::</span><span class="ruby-constant">Document</span>.<span class="ruby-identifier">new</span>(<span class="ruby-string">&#39;&lt;root&gt;&lt;a/&gt;text&lt;b/&gt;more&lt;c/&gt;&lt;/root&gt;&#39;</span>)
<span class="ruby-identifier">t</span> = <span class="ruby-identifier">d</span>.<span class="ruby-identifier">root</span>[<span class="ruby-value">1</span>] <span class="ruby-comment"># =&gt; &quot;text&quot;</span>
<span class="ruby-identifier">t</span>.<span class="ruby-identifier">parent?</span>     <span class="ruby-comment"># =&gt; false</span>
</pre>

<p>Class Parent also derives from Node, but overrides this method:</p>

<pre class="ruby"><span class="ruby-identifier">p</span> = <span class="ruby-constant">REXML</span><span class="ruby-operator">::</span><span class="ruby-constant">Parent</span>.<span class="ruby-identifier">new</span>
<span class="ruby-identifier">p</span>.<span class="ruby-identifier">parent?</span> <span class="ruby-comment"># =&gt; true</span>
</pre>

<h3 id="label-Additions">Additions<span><a href="#label-Additions">&para;</a> <a href="#top">&uarr;</a></span></h3>

<h4 id="label-Task-3A+Add+a+Child+at+the+Beginning">Task: Add a Child at the Beginning<span><a href="#label-Task-3A+Add+a+Child+at+the+Beginning">&para;</a> <a href="#top">&uarr;</a></span></h4>

<p>Use method <a href="../../../../REXML/Parent.html#method-i-unshift">Parent#unshift</a> to add a child as at the beginning of the children:</p>

<pre class="ruby"><span class="ruby-identifier">xml_string</span> = <span class="ruby-string">&#39;&lt;root&gt;&lt;a/&gt;&lt;b/&gt;&lt;c/&gt;&lt;/root&gt;&#39;</span>
<span class="ruby-identifier">d</span> = <span class="ruby-constant">REXML</span><span class="ruby-operator">::</span><span class="ruby-constant">Document</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">xml_string</span>)
<span class="ruby-identifier">d</span>.<span class="ruby-identifier">root</span>.<span class="ruby-identifier">children</span> <span class="ruby-comment"># =&gt; [&lt;a/&gt;, &lt;b/&gt;, &lt;c/&gt;]</span>
<span class="ruby-identifier">d</span>.<span class="ruby-identifier">root</span>.<span class="ruby-identifier">unshift</span> <span class="ruby-constant">REXML</span><span class="ruby-operator">::</span><span class="ruby-constant">Element</span>.<span class="ruby-identifier">new</span>(<span class="ruby-string">&#39;d&#39;</span>)
<span class="ruby-identifier">d</span>.<span class="ruby-identifier">root</span>.<span class="ruby-identifier">children</span> <span class="ruby-comment"># =&gt; [&lt;d/&gt;, &lt;a/&gt;, &lt;b/&gt;, &lt;c/&gt;]</span>
</pre>

<h4 id="label-Task-3A+Add+a+Child+at+the+End">Task: Add a Child at the End<span><a href="#label-Task-3A+Add+a+Child+at+the+End">&para;</a> <a href="#top">&uarr;</a></span></h4>

<p>Use method <a href="../../../../REXML/Parent.html#method-i-3C-3C">Parent#<<</a> (or an alias <code>push</code> or <code>add</code>) to add a child as at the end of the children:</p>

<pre class="ruby"><span class="ruby-identifier">xml_string</span> = <span class="ruby-string">&#39;&lt;root&gt;&lt;a/&gt;&lt;b/&gt;&lt;c/&gt;&lt;/root&gt;&#39;</span>
<span class="ruby-identifier">d</span> = <span class="ruby-constant">REXML</span><span class="ruby-operator">::</span><span class="ruby-constant">Document</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">xml_string</span>)
<span class="ruby-identifier">d</span>.<span class="ruby-identifier">root</span>.<span class="ruby-identifier">children</span> <span class="ruby-comment"># =&gt; [&lt;a/&gt;, &lt;b/&gt;, &lt;c/&gt;]</span>
<span class="ruby-identifier">d</span>.<span class="ruby-identifier">root</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-constant">REXML</span><span class="ruby-operator">::</span><span class="ruby-constant">Element</span>.<span class="ruby-identifier">new</span>(<span class="ruby-string">&#39;d&#39;</span>)
<span class="ruby-identifier">d</span>.<span class="ruby-identifier">root</span>.<span class="ruby-identifier">children</span> <span class="ruby-comment"># =&gt; [&lt;a/&gt;, &lt;b/&gt;, &lt;c/&gt;, &lt;d/&gt;]</span>
</pre>

<h4 id="label-Task-3A+Replace+a+Child+with+Another+Child">Task: Replace a Child with Another Child<span><a href="#label-Task-3A+Replace+a+Child+with+Another+Child">&para;</a> <a href="#top">&uarr;</a></span></h4>

<p>Use method <a href="../../../../REXML/Parent.html#method-i-replace">Parent#replace</a></p>

<pre class="ruby"><span class="ruby-identifier">xml_string</span> = <span class="ruby-string">&#39;&lt;root&gt;&lt;a/&gt;&lt;b/&gt;&lt;c/&gt;&lt;/root&gt;&#39;</span>
<span class="ruby-identifier">d</span> = <span class="ruby-constant">REXML</span><span class="ruby-operator">::</span><span class="ruby-constant">Document</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">xml_string</span>)
<span class="ruby-identifier">d</span>.<span class="ruby-identifier">root</span>.<span class="ruby-identifier">children</span> <span class="ruby-comment"># =&gt; [&lt;a/&gt;, &lt;b/&gt;, &lt;c/&gt;]</span>
<span class="ruby-identifier">b</span> = <span class="ruby-identifier">d</span>.<span class="ruby-identifier">root</span>[<span class="ruby-value">1</span>]   <span class="ruby-comment"># =&gt; &lt;b/&gt;</span>
<span class="ruby-identifier">d</span>.<span class="ruby-identifier">replace_child</span>(<span class="ruby-identifier">b</span>, <span class="ruby-constant">REXML</span><span class="ruby-operator">::</span><span class="ruby-constant">Element</span>.<span class="ruby-identifier">new</span>(<span class="ruby-string">&#39;d&#39;</span>))
<span class="ruby-identifier">d</span>.<span class="ruby-identifier">root</span>.<span class="ruby-identifier">children</span> <span class="ruby-comment"># =&gt; [&lt;a/&gt;, &lt;c/&gt;]</span>
</pre>

<h4 id="label-Task-3A+Replace+Multiple+Children+with+Another+Child">Task: Replace Multiple Children with Another Child<span><a href="#label-Task-3A+Replace+Multiple+Children+with+Another+Child">&para;</a> <a href="#top">&uarr;</a></span></h4>

<p>Use method <a href="../../../../REXML/Parent.html#method-i-parent-5B-5D-3D">Parent#[]=</a> to replace multiple consecutive children with another child:</p>

<pre class="ruby"><span class="ruby-identifier">xml_string</span> = <span class="ruby-string">&#39;&lt;root&gt;&lt;a/&gt;&lt;b/&gt;&lt;c/&gt;&lt;d/&gt;&lt;/root&gt;&#39;</span>
<span class="ruby-identifier">d</span> = <span class="ruby-constant">REXML</span><span class="ruby-operator">::</span><span class="ruby-constant">Document</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">xml_string</span>)
<span class="ruby-identifier">d</span>.<span class="ruby-identifier">root</span>.<span class="ruby-identifier">children</span> <span class="ruby-comment"># =&gt; [&lt;a/&gt;, &lt;b/&gt;, &lt;c/&gt;, &lt;d/&gt;]</span>
<span class="ruby-identifier">d</span>.<span class="ruby-identifier">root</span>[<span class="ruby-value">1</span>, <span class="ruby-value">2</span>] = <span class="ruby-constant">REXML</span><span class="ruby-operator">::</span><span class="ruby-constant">Element</span>.<span class="ruby-identifier">new</span>(<span class="ruby-string">&#39;x&#39;</span>)
<span class="ruby-identifier">d</span>.<span class="ruby-identifier">root</span>.<span class="ruby-identifier">children</span> <span class="ruby-comment"># =&gt; [&lt;a/&gt;, &lt;x/&gt;, &lt;d/&gt;]</span>
<span class="ruby-identifier">d</span>.<span class="ruby-identifier">root</span>[<span class="ruby-value">1</span>, <span class="ruby-value">5</span>] = <span class="ruby-constant">REXML</span><span class="ruby-operator">::</span><span class="ruby-constant">Element</span>.<span class="ruby-identifier">new</span>(<span class="ruby-string">&#39;x&#39;</span>)
<span class="ruby-identifier">d</span>.<span class="ruby-identifier">root</span>.<span class="ruby-identifier">children</span> <span class="ruby-comment"># =&gt; [&lt;a/&gt;, &lt;x/&gt;] # BUG?</span>
</pre>

<h4 id="label-Task-3A+Insert+Child+Before+a+Given+Child">Task: Insert Child Before a Given Child<span><a href="#label-Task-3A+Insert+Child+Before+a+Given+Child">&para;</a> <a href="#top">&uarr;</a></span></h4>

<p>Use method <a href="../../../../REXML/Parent.html#method-i-insert_before">Parent#insert_before</a> to insert a child immediately before a given child:</p>

<pre class="ruby"><span class="ruby-identifier">xml_string</span> = <span class="ruby-string">&#39;&lt;root&gt;&lt;a/&gt;&lt;b/&gt;&lt;c/&gt;&lt;/root&gt;&#39;</span>
<span class="ruby-identifier">d</span> = <span class="ruby-constant">REXML</span><span class="ruby-operator">::</span><span class="ruby-constant">Document</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">xml_string</span>)
<span class="ruby-identifier">d</span>.<span class="ruby-identifier">root</span>.<span class="ruby-identifier">children</span> <span class="ruby-comment"># =&gt; [&lt;a/&gt;, &lt;b/&gt;, &lt;c/&gt;]</span>
<span class="ruby-identifier">b</span> = <span class="ruby-identifier">d</span>.<span class="ruby-identifier">root</span>[<span class="ruby-value">1</span>]   <span class="ruby-comment"># =&gt; &lt;b/&gt;</span>
<span class="ruby-identifier">x</span> = <span class="ruby-constant">REXML</span><span class="ruby-operator">::</span><span class="ruby-constant">Element</span>.<span class="ruby-identifier">new</span>(<span class="ruby-string">&#39;x&#39;</span>)
<span class="ruby-identifier">d</span>.<span class="ruby-identifier">root</span>.<span class="ruby-identifier">insert_before</span>(<span class="ruby-identifier">b</span>, <span class="ruby-identifier">x</span>)
<span class="ruby-identifier">d</span>.<span class="ruby-identifier">root</span>.<span class="ruby-identifier">children</span> <span class="ruby-comment"># =&gt; [&lt;a/&gt;, &lt;x/&gt;, &lt;b/&gt;, &lt;c/&gt;]</span>
</pre>

<h4 id="label-Task-3A+Insert+Child+After+a+Given+Child">Task: Insert Child After a Given Child<span><a href="#label-Task-3A+Insert+Child+After+a+Given+Child">&para;</a> <a href="#top">&uarr;</a></span></h4>

<p>Use method <a href="../../../../REXML/Parent.html#method-i-insert_after">Parent#insert_after</a> to insert a child immediately after a given child:</p>

<pre class="ruby"><span class="ruby-identifier">xml_string</span> = <span class="ruby-string">&#39;&lt;root&gt;&lt;a/&gt;&lt;b/&gt;&lt;c/&gt;&lt;/root&gt;&#39;</span>
<span class="ruby-identifier">d</span> = <span class="ruby-constant">REXML</span><span class="ruby-operator">::</span><span class="ruby-constant">Document</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">xml_string</span>)
<span class="ruby-identifier">d</span>.<span class="ruby-identifier">root</span>.<span class="ruby-identifier">children</span> <span class="ruby-comment"># =&gt; [&lt;a/&gt;, &lt;b/&gt;, &lt;c/&gt;]</span>
<span class="ruby-identifier">b</span> = <span class="ruby-identifier">d</span>.<span class="ruby-identifier">root</span>[<span class="ruby-value">1</span>]   <span class="ruby-comment"># =&gt; &lt;b/&gt;</span>
<span class="ruby-identifier">x</span> = <span class="ruby-constant">REXML</span><span class="ruby-operator">::</span><span class="ruby-constant">Element</span>.<span class="ruby-identifier">new</span>(<span class="ruby-string">&#39;x&#39;</span>)
<span class="ruby-identifier">d</span>.<span class="ruby-identifier">root</span>.<span class="ruby-identifier">insert_after</span>(<span class="ruby-identifier">b</span>, <span class="ruby-identifier">x</span>)
<span class="ruby-identifier">d</span>.<span class="ruby-identifier">root</span>.<span class="ruby-identifier">children</span> <span class="ruby-comment"># =&gt; [&lt;a/&gt;, &lt;b/&gt;, &lt;x/&gt;, &lt;c/&gt;]</span>
</pre>

<h3 id="label-Deletions">Deletions<span><a href="#label-Deletions">&para;</a> <a href="#top">&uarr;</a></span></h3>

<h4 id="label-Task-3A+Remove+a+Given+Child">Task: Remove a Given Child<span><a href="#label-Task-3A+Remove+a+Given+Child">&para;</a> <a href="#top">&uarr;</a></span></h4>

<p>Use method <a href="../../../../REXML/Parent.html#method-i-delete">Parent#delete</a> to remove all occurrences of a given child:</p>

<pre class="ruby"><span class="ruby-identifier">d</span> = <span class="ruby-constant">REXML</span><span class="ruby-operator">::</span><span class="ruby-constant">Document</span>.<span class="ruby-identifier">new</span>(<span class="ruby-string">&#39;&lt;root&gt;&lt;/root&gt;&#39;</span>)
<span class="ruby-identifier">a</span> = <span class="ruby-constant">REXML</span><span class="ruby-operator">::</span><span class="ruby-constant">Element</span>.<span class="ruby-identifier">new</span>(<span class="ruby-string">&#39;a&#39;</span>)
<span class="ruby-identifier">b</span> = <span class="ruby-constant">REXML</span><span class="ruby-operator">::</span><span class="ruby-constant">Element</span>.<span class="ruby-identifier">new</span>(<span class="ruby-string">&#39;b&#39;</span>)
<span class="ruby-identifier">d</span>.<span class="ruby-identifier">root</span>.<span class="ruby-identifier">add</span>(<span class="ruby-identifier">a</span>)
<span class="ruby-identifier">d</span>.<span class="ruby-identifier">root</span>.<span class="ruby-identifier">add</span>(<span class="ruby-identifier">b</span>)
<span class="ruby-identifier">d</span>.<span class="ruby-identifier">root</span>.<span class="ruby-identifier">add</span>(<span class="ruby-identifier">a</span>)
<span class="ruby-identifier">d</span>.<span class="ruby-identifier">root</span>.<span class="ruby-identifier">add</span>(<span class="ruby-identifier">b</span>)
<span class="ruby-identifier">d</span>.<span class="ruby-identifier">root</span>.<span class="ruby-identifier">children</span> <span class="ruby-comment"># =&gt; [&lt;a/&gt;, &lt;b/&gt;, &lt;a/&gt;, &lt;b/&gt;]</span>
<span class="ruby-identifier">d</span>.<span class="ruby-identifier">root</span>.<span class="ruby-identifier">delete</span>(<span class="ruby-identifier">b</span>)
<span class="ruby-identifier">d</span>.<span class="ruby-identifier">root</span>.<span class="ruby-identifier">children</span> <span class="ruby-comment"># =&gt; [&lt;a/&gt;, &lt;a/&gt;]</span>
</pre>

<h4 id="label-Task-3A+Remove+the+Child+at+a+Specified+Offset">Task: Remove the Child at a Specified Offset<span><a href="#label-Task-3A+Remove+the+Child+at+a+Specified+Offset">&para;</a> <a href="#top">&uarr;</a></span></h4>

<p>Use method <a href="../../../../REXML/Parent.html#method-i-delete_at">Parent#delete_at</a> to remove the child at a specified offset:</p>

<pre class="ruby"><span class="ruby-identifier">d</span> = <span class="ruby-constant">REXML</span><span class="ruby-operator">::</span><span class="ruby-constant">Document</span>.<span class="ruby-identifier">new</span>(<span class="ruby-string">&#39;&lt;root&gt;&lt;/root&gt;&#39;</span>)
<span class="ruby-identifier">a</span> = <span class="ruby-constant">REXML</span><span class="ruby-operator">::</span><span class="ruby-constant">Element</span>.<span class="ruby-identifier">new</span>(<span class="ruby-string">&#39;a&#39;</span>)
<span class="ruby-identifier">b</span> = <span class="ruby-constant">REXML</span><span class="ruby-operator">::</span><span class="ruby-constant">Element</span>.<span class="ruby-identifier">new</span>(<span class="ruby-string">&#39;b&#39;</span>)
<span class="ruby-identifier">d</span>.<span class="ruby-identifier">root</span>.<span class="ruby-identifier">add</span>(<span class="ruby-identifier">a</span>)
<span class="ruby-identifier">d</span>.<span class="ruby-identifier">root</span>.<span class="ruby-identifier">add</span>(<span class="ruby-identifier">b</span>)
<span class="ruby-identifier">d</span>.<span class="ruby-identifier">root</span>.<span class="ruby-identifier">add</span>(<span class="ruby-identifier">a</span>)
<span class="ruby-identifier">d</span>.<span class="ruby-identifier">root</span>.<span class="ruby-identifier">add</span>(<span class="ruby-identifier">b</span>)
<span class="ruby-identifier">d</span>.<span class="ruby-identifier">root</span>.<span class="ruby-identifier">children</span> <span class="ruby-comment"># =&gt; [&lt;a/&gt;, &lt;b/&gt;, &lt;a/&gt;, &lt;b/&gt;]</span>
<span class="ruby-identifier">d</span>.<span class="ruby-identifier">root</span>.<span class="ruby-identifier">delete_at</span>(<span class="ruby-value">2</span>)
<span class="ruby-identifier">d</span>.<span class="ruby-identifier">root</span>.<span class="ruby-identifier">children</span> <span class="ruby-comment"># =&gt; [&lt;a/&gt;, &lt;b/&gt;, &lt;b/&gt;]</span>
</pre>

<h4 id="label-Task-3A+Remove+Children+That+Meet+Specified+Criteria">Task: Remove Children That Meet Specified Criteria<span><a href="#label-Task-3A+Remove+Children+That+Meet+Specified+Criteria">&para;</a> <a href="#top">&uarr;</a></span></h4>

<p>Use method <a href="../../../../REXML/Parent.html#method-i-delete_if">Parent#delete_if</a> to remove children that meet criteria specified in the given block:</p>

<pre class="ruby"><span class="ruby-identifier">d</span> = <span class="ruby-constant">REXML</span><span class="ruby-operator">::</span><span class="ruby-constant">Document</span>.<span class="ruby-identifier">new</span>(<span class="ruby-string">&#39;&lt;root&gt;&lt;/root&gt;&#39;</span>)
<span class="ruby-identifier">d</span>.<span class="ruby-identifier">root</span>.<span class="ruby-identifier">add</span>(<span class="ruby-constant">REXML</span><span class="ruby-operator">::</span><span class="ruby-constant">Element</span>.<span class="ruby-identifier">new</span>(<span class="ruby-string">&#39;x&#39;</span>))
<span class="ruby-identifier">d</span>.<span class="ruby-identifier">root</span>.<span class="ruby-identifier">add</span>(<span class="ruby-constant">REXML</span><span class="ruby-operator">::</span><span class="ruby-constant">Element</span>.<span class="ruby-identifier">new</span>(<span class="ruby-string">&#39;xx&#39;</span>))
<span class="ruby-identifier">d</span>.<span class="ruby-identifier">root</span>.<span class="ruby-identifier">add</span>(<span class="ruby-constant">REXML</span><span class="ruby-operator">::</span><span class="ruby-constant">Element</span>.<span class="ruby-identifier">new</span>(<span class="ruby-string">&#39;xxx&#39;</span>))
<span class="ruby-identifier">d</span>.<span class="ruby-identifier">root</span>.<span class="ruby-identifier">add</span>(<span class="ruby-constant">REXML</span><span class="ruby-operator">::</span><span class="ruby-constant">Element</span>.<span class="ruby-identifier">new</span>(<span class="ruby-string">&#39;xxxx&#39;</span>))
<span class="ruby-identifier">d</span>.<span class="ruby-identifier">root</span>.<span class="ruby-identifier">children</span> <span class="ruby-comment"># =&gt; [&lt;x/&gt;, &lt;xx/&gt;, &lt;xxx/&gt;, &lt;xxxx/&gt;]</span>
<span class="ruby-identifier">d</span>.<span class="ruby-identifier">root</span>.<span class="ruby-identifier">delete_if</span> {<span class="ruby-operator">|</span><span class="ruby-identifier">child</span><span class="ruby-operator">|</span> <span class="ruby-identifier">child</span>.<span class="ruby-identifier">name</span>.<span class="ruby-identifier">size</span>.<span class="ruby-identifier">odd?</span> }
<span class="ruby-identifier">d</span>.<span class="ruby-identifier">root</span>.<span class="ruby-identifier">children</span> <span class="ruby-comment"># =&gt; [&lt;xx/&gt;, &lt;xxxx/&gt;]</span>
</pre>

<h3 id="label-Iterations">Iterations<span><a href="#label-Iterations">&para;</a> <a href="#top">&uarr;</a></span></h3>

<h4 id="label-Task-3A+Iterate+Over+Children">Task: Iterate Over Children<span><a href="#label-Task-3A+Iterate+Over+Children">&para;</a> <a href="#top">&uarr;</a></span></h4>

<p>Use method <a href="../../../../REXML/Parent.html#method-i-each_child">Parent#each_child</a> (or its alias <code>each</code>) to iterate over all children:</p>

<pre class="ruby"><span class="ruby-identifier">xml_string</span> = <span class="ruby-string">&#39;&lt;root&gt;&lt;a/&gt;&lt;b/&gt;&lt;c/&gt;&lt;/root&gt;&#39;</span>
<span class="ruby-identifier">d</span> = <span class="ruby-constant">REXML</span><span class="ruby-operator">::</span><span class="ruby-constant">Document</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">xml_string</span>)
<span class="ruby-identifier">d</span>.<span class="ruby-identifier">root</span>.<span class="ruby-identifier">children</span> <span class="ruby-comment"># =&gt; [&lt;a/&gt;, &lt;b/&gt;, &lt;c/&gt;]</span>
<span class="ruby-identifier">d</span>.<span class="ruby-identifier">root</span>.<span class="ruby-identifier">each_child</span> {<span class="ruby-operator">|</span><span class="ruby-identifier">child</span><span class="ruby-operator">|</span> <span class="ruby-identifier">p</span> <span class="ruby-identifier">child</span> }
</pre>

<p>Output:</p>

<pre>&lt;a/&gt;
&lt;b/&gt;
&lt;c/&gt;</pre>

<h4 id="label-Task-3A+Iterate+Over+Child+Indexes">Task: Iterate Over Child Indexes<span><a href="#label-Task-3A+Iterate+Over+Child+Indexes">&para;</a> <a href="#top">&uarr;</a></span></h4>

<p>Use method <a href="../../../../REXML/Parent.html#method-i-each_index">Parent#each_index</a> to iterate over all child indexes:</p>

<pre class="ruby"><span class="ruby-identifier">xml_string</span> = <span class="ruby-string">&#39;&lt;root&gt;&lt;a/&gt;&lt;b/&gt;&lt;c/&gt;&lt;/root&gt;&#39;</span>
<span class="ruby-identifier">d</span> = <span class="ruby-constant">REXML</span><span class="ruby-operator">::</span><span class="ruby-constant">Document</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">xml_string</span>)
<span class="ruby-identifier">d</span>.<span class="ruby-identifier">root</span>.<span class="ruby-identifier">children</span> <span class="ruby-comment"># =&gt; [&lt;a/&gt;, &lt;b/&gt;, &lt;c/&gt;]</span>
<span class="ruby-identifier">d</span>.<span class="ruby-identifier">root</span>.<span class="ruby-identifier">each_index</span> {<span class="ruby-operator">|</span><span class="ruby-identifier">child</span><span class="ruby-operator">|</span> <span class="ruby-identifier">p</span> <span class="ruby-identifier">child</span> }
</pre>

<p>Output:</p>

<pre class="ruby"><span class="ruby-value">0</span>
<span class="ruby-value">1</span>
<span class="ruby-value">2</span>
</pre>

<h3 id="label-Clones">Clones<span><a href="#label-Clones">&para;</a> <a href="#top">&uarr;</a></span></h3>

<h4 id="label-Task-3A+Clone+Deeply">Task: Clone Deeply<span><a href="#label-Task-3A+Clone+Deeply">&para;</a> <a href="#top">&uarr;</a></span></h4>

<p>Use method <a href="../../../../REXML/Parent.html#method-i-deep_clone">Parent#deep_clone</a> to clone deeply; that is, to clone every nested node that is a Parent object:</p>

<pre class="ruby"><span class="ruby-identifier">xml_string</span> = <span class="ruby-identifier">&lt;&lt;-EOT</span>
<span class="ruby-value">  &lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
  &lt;bookstore&gt;
    &lt;book category=&quot;cooking&quot;&gt;
      &lt;title lang=&quot;en&quot;&gt;Everyday Italian&lt;/title&gt;
      &lt;author&gt;Giada De Laurentiis&lt;/author&gt;
      &lt;year&gt;2005&lt;/year&gt;
      &lt;price&gt;30.00&lt;/price&gt;
    &lt;/book&gt;
    &lt;book category=&quot;children&quot;&gt;
      &lt;title lang=&quot;en&quot;&gt;Harry Potter&lt;/title&gt;
      &lt;author&gt;J K. Rowling&lt;/author&gt;
      &lt;year&gt;2005&lt;/year&gt;
      &lt;price&gt;29.99&lt;/price&gt;
    &lt;/book&gt;
    &lt;book category=&quot;web&quot;&gt;
      &lt;title lang=&quot;en&quot;&gt;Learning XML&lt;/title&gt;
      &lt;author&gt;Erik T. Ray&lt;/author&gt;
      &lt;year&gt;2003&lt;/year&gt;
      &lt;price&gt;39.95&lt;/price&gt;
    &lt;/book&gt;
  &lt;/bookstore&gt;
</span><span class="ruby-identifier">EOT</span>
<span class="ruby-identifier">d</span> = <span class="ruby-constant">REXML</span><span class="ruby-operator">::</span><span class="ruby-constant">Document</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">xml_string</span>)
<span class="ruby-identifier">root</span> = <span class="ruby-identifier">d</span>.<span class="ruby-identifier">root</span>
<span class="ruby-identifier">shallow</span> = <span class="ruby-identifier">root</span>.<span class="ruby-identifier">clone</span>
<span class="ruby-identifier">deep</span> = <span class="ruby-identifier">root</span>.<span class="ruby-identifier">deep_clone</span>
<span class="ruby-identifier">shallow</span>.<span class="ruby-identifier">to_s</span>.<span class="ruby-identifier">size</span> <span class="ruby-comment"># =&gt; 12</span>
<span class="ruby-identifier">deep</span>.<span class="ruby-identifier">to_s</span>.<span class="ruby-identifier">size</span>    <span class="ruby-comment"># =&gt; 590</span>
</pre>

</main>

</div>  <!--  class='wrapper hdiv' -->


<footer id="validator-badges" role="contentinfo">
<p><a href="https://validator.w3.org/check/referer">Validate</a></p>
<p>Generated by <a href="https://ruby.github.io/rdoc/">RDoc</a> 6.4.0.</p>
<p>Based on <a href="https://github.com/ged/darkfish/">Darkfish</a> by <a href="http://deveiate.org">Michael Granger</a>.</p>

  
    <p><p><a href="https://ruby-doc.org">Ruby-doc.org</a> is provided by <a href="https://jamesbritt.com">James Britt</a> and <a href="https://neurogami.com">Neurogami</a>.</p><p><a href="https://jamesbritt.bandcamp.com/">Maximum R+D</a>.  </p>
</p>
  
  </footer>

<script type="text/javascript">


  let ads  = $("#carbonads-container").children().detach();


  function swapMode() {
    var cookieName = 'darkmode';
    var cssDarkmode = Cookies.get(cookieName);
    console.log("***** swapMode! " + cssDarkmode + " *****");


    if (cssDarkmode == "true") {
      console.log("We have dark mode, set the css to light ...");
      $('#rdoccss').attr("href", defaultModeCssHref);
      $('#cssSelect').text("Dark mode");
      cssDarkmode = "false";
      console.log("swapMode! Now set cookie to " + cssDarkmode);
      Cookies.set(cookieName, cssDarkmode);

    } else {
      console.log("We not have dark mode, set the css to dark ...");
      $('#rdoccss').attr("href", darkModeCsseHref);
      $('#cssSelect').text("Light mode");
      cssDarkmode = "true";
      console.log("swapMode! Now set cookie to " + cssDarkmode);
      Cookies.set(cookieName, cssDarkmode);

    }

    console.log("  --------------- ");
  }


const vueCssApp = new Vue({
el: '#menubar',
data: {
isDark: false
},
methods: {
toggleClass: function(event){
this.isDark = !this.isDark;
}
}
})

const vueApp = new Vue({
el: '#vapp',
data: { 
isOpen: true
},

mounted() {
this.handleResize();
this.manage_mob_classes();
window.addEventListener('resize', this.handleResize)
//this.isOpen !=  (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent));
},
destroyed() {
window.removeEventListener('resize', this.handleResize)
},
created() {
//manage_mob_classes();
},

methods : {
isMobile() {
  return (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent));
},

  handleResize() {
    if (!this.isMobile()) {
      this.isOpen = window.innerWidth > 800;
    }
  },

  manage_mob_classes() {
    if (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)) {
      $("nav").addClass("mob_nav");
      $("main").addClass("mob_main");
      $("#extraz").addClass("mob_extraz");
      $("#carbonads-container").addClass("mob_carbonads-container");
      this.isOpen  = false;
    } else {
      $("nav").removeClass("mob_nav") 
        $("main").removeClass("mob_main");
      $("#extraz").removeClass("mob_extraz");
      $("#carbonads-container").removeClass("mob_carbonads-container");
      this.isOpen  = true;
    }
  },

  toggleNav() {
    this.isOpen =! this.isOpen ;
    // alert("Toggle nav!");
    console.log("toggleNav() click: " + this.isOpen );
  }
}
})

$("#carbonads-container").append(ads);


$(function() {

    var darkmode = Cookies.get("darkmode");
    console.log("Document ready: " + darkmode);

    if ( darkmode  == "true" ) {
      $('#cssSelect').text("Light mode");
    } else {
      $('#cssSelect').text("Dark mode");
     }

    $('body').css('display','block');
    });

</script>

    
  </body> 
</html>

